from rest_framework import serializers
from .models import *
from .views import *


# 资源的序列化器
class LearningMaterialSer(serializers.ModelSerializer):
    class Meta:
        model = LearningMaterialsModel
        fields = ['id','name','user_id','price','desc','count','image','create_date']
        read_only_fields = ['id', 'user_id']


# 学习任务的序列化器
class StudyContentSer(serializers.ModelSerializer):
    class Meta:
        model = StudyContentModel
        fields = ['id','title','user_id','content','desc','class_id','is_overt','label','label_id','create_date']


# 分类序列化器
class ClassSer(serializers.ModelSerializer):
    class Meta:
        model = ClassModel
        fields = ['id','name', 'school_id']


# 收藏的序列化器
class CollectSer(serializers.ModelSerializer):
    class Meta:
        model = CollectModel
        fields = "__all__"